namespace SinaFinance
{
    using SinaFinance.ChartLibrary.AxisLibrary;
    using SinaFinance.ChartLibrary.StockTopFiveChangesLibrary;
    using SinaFinance.MainChartArea;
    using SinaFinance.SummaryInfoLibrary;
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Diagnostics;
    using System.Linq;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;

    public partial class MainPage : UserControl
    {
        //private bool _contentLoaded;
        //internal Canvas BasicInfoCanvas;
        //internal Border border;
        //internal Border border1;
        //internal Grid BottomGrid;
        //internal TextBlock btnFullScreemChart;
        //internal Canvas canvasF;
        //internal Canvas canvasK;
        //internal Canvas canvasT;
        private const double CHARTAREAHEIGHT = 400.0;
        private const double CHARTAREAWIDTH = 700.0;
        //internal Canvas ChartCanvas;
        private StockChartCover cover = new StockChartCover();
        //internal Grid full;
        //internal Border fullScreen;
        //internal Storyboard fullScreenMouseEnter;
        //internal Storyboard fullScreenMouseEnter_Copy1;
        private const double HorizontalAlignmentInterval = 10.0;
        private bool isLoad = true;
        private KDayAxis kDayAxis;
        //internal Border Kline;
        //internal Storyboard KlineMouseEnter;
        //internal Storyboard KlineMouseEnter_Copy1;
        //internal Grid LayoutRoot;
        private string MainTargetID = string.Empty;
        //internal Grid MidGrid;
        //internal Canvas NewsCanvas;
        private StockProfessionInformationArea newsInfoArea;
        //internal Path path;
        //internal Path path1;
        //internal Path path2;
        //internal Canvas popSearchArea;
        //internal Grid right;
        private StockBasicInfo sbinfo;
        private ScaleTransform scaleTransform = new ScaleTransform();
        private double scaleValue = 0.0;
        //internal ScrollViewer scrollViewer;
        //internal Canvas SearchCanvas;
        private SearchSuggestHistory searchSgstHistory;
        private const string SHANGZHENG = "sh000001";
        private const string SHENZHI = "sz399001";
        private Collection<UserControl> slides;
        private SlideShow slideShow;
        //internal Storyboard start;
        private string STOCKID = "sh000001";
        //internal Canvas StockTopFiveCanvas;
        private StockTopFiveChanges stockTopFiveChanges;
        //internal Border Timeborder;
        //internal Storyboard timeMouseEnter;
        //internal Storyboard timeMouseEnter_Copy1;
        private TimeSharingAxis timeSharingAxis;
        //internal Grid top;
        //internal Canvas topInfoCanvas;
        private TopStockView tsvInfo;

        public MainPage()
        {
            this.InitializeComponent();
            base.Loaded += new RoutedEventHandler(this.MainPage_Loaded);
            this.start.Begin();
            this.top.SetValue(Canvas.ZIndexProperty, 100);
            this.right.SetValue(Canvas.ZIndexProperty, 100);
            this.Timeborder.MouseEnter += new MouseEventHandler(this.Timeborder_MouseEnter);
            this.Timeborder.MouseLeave += new MouseEventHandler(this.Timeborder_MouseLeave);
            this.Kline.MouseEnter += new MouseEventHandler(this.Kline_MouseEnter);
            this.Kline.MouseLeave += new MouseEventHandler(this.Kline_MouseLeave);
            this.fullScreen.MouseEnter += new MouseEventHandler(this.fullScreen_MouseEnter);
            this.fullScreen.MouseLeave += new MouseEventHandler(this.fullScreen_MouseLeave);
            this.LayoutRoot.MouseLeftButtonDown += new MouseButtonEventHandler(this.LayoutRoot_MouseLeftButtonDown);
            Application.Current.Host.Content.FullScreenChanged += new System.EventHandler(this.Content_FullScreenChanged);
            Application.Current.Host.Content.Resized += new System.EventHandler(this.Content_Resized);
        }

        private void btnFullScreemChart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen;
            this.btnFullScreemChart.Text = "默认";
            double actualHeight = Application.Current.Host.Content.ActualHeight;
            double actualWidth = Application.Current.Host.Content.ActualWidth;
            double num3 = Convert.ToDouble(this.MidGrid.ColumnDefinitions[1].Width.ToString());
            double num4 = Convert.ToDouble(this.MidGrid.ColumnDefinitions[2].Width.ToString());
            double num5 = this.ChartCanvas.ActualHeight;
            double num6 = num3 + num4;
            this.MidGrid.ColumnDefinitions[0].Width = new GridLength(0.0);
            this.MidGrid.ColumnDefinitions[3].Width = new GridLength(0.0);
            double num7 = ((actualWidth - num4) - 30.0) / num3;
            this.MidGrid.ColumnDefinitions[1].Width = new GridLength((actualWidth - Convert.ToDouble(num4.ToString())) - 30.0);
            this.scaleValue = num7;
            this.scaleTransform.ScaleX = this.scaleValue;
            if ((this.scaleValue * num5) > ((actualHeight - this.top.ActualHeight) - this.BottomGrid.ActualHeight))
            {
                this.scaleTransform.ScaleY = ((actualHeight - this.top.ActualHeight) - this.BottomGrid.ActualHeight) / num5;
            }
            else
            {
                this.scaleTransform.ScaleY = this.scaleValue;
            }
            this.scaleTransform.CenterX = 0.0;
            this.scaleTransform.CenterY = 0.0;
            this.ChartCanvas.RenderTransform = this.scaleTransform;
            double num8 = Convert.ToDouble(this.MidGrid.ColumnDefinitions[1].Width.ToString());
            this.sbinfo.setBorderWidth(num8, num8);
            this.path2.Fill = new SolidColorBrush(Colors.Red);
        }

        private void btnKLineChart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.slideShow != null)
            {
                this.path.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x8d, 0x8d, 0x8d));
                this.path1.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x40, 130, 0xff));
                this.slideShow.GoPreviewPage();
                this.cover.Type = StockChartCover.StockChartTypeEnum.KLine;
            }
        }

        private void btnTimeSharingChart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.slideShow != null)
            {
                this.path.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x40, 130, 0xff));
                this.path1.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x8d, 0x8d, 0x8d));
                this.slideShow.GoNextPage();
                this.cover.Type = StockChartCover.StockChartTypeEnum.TimeSharing;
            }
        }

        private void Content_FullScreenChanged(object sender, EventArgs e)
        {
            if (!Application.Current.Host.Content.IsFullScreen)
            {
                this.path2.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x8d, 0x8d, 0x8d));
                this.searchSgstHistory.Visibility = Visibility.Visible;
                this.btnFullScreemChart.Text = "全屏";
                double actualHeight = Application.Current.Host.Content.ActualHeight;
                double actualWidth = Application.Current.Host.Content.ActualWidth;
                double num3 = Convert.ToDouble(this.MidGrid.ColumnDefinitions[1].Width.ToString());
                double num4 = Convert.ToDouble(this.MidGrid.ColumnDefinitions[2].Width.ToString());
                double num5 = 715.0 / num3;
                this.MidGrid.ColumnDefinitions[1].Width = new GridLength(715.0);
                double pixels = (((actualWidth - 715.0) - num4) - 20.0) / 2.0;
                pixels = (pixels > 0.0) ? pixels : 0.0;
                this.MidGrid.ColumnDefinitions[0].Width = new GridLength(pixels);
                this.MidGrid.ColumnDefinitions[3].Width = new GridLength(pixels);
                this.scaleValue = num5;
                this.scaleTransform.ScaleX = 1.0;
                this.scaleTransform.ScaleY = 1.0;
                this.scaleTransform.CenterX = 0.0;
                this.scaleTransform.CenterY = 0.0;
                this.ChartCanvas.RenderTransform = this.scaleTransform;
                double num7 = Convert.ToDouble(this.MidGrid.ColumnDefinitions[1].Width.ToString());
                this.sbinfo.setBorderWidth(num7, num7);
            }
        }

        private void Content_Resized(object sender, EventArgs e)
        {
            double actualHeight = Application.Current.Host.Content.ActualHeight;
            double actualWidth = Application.Current.Host.Content.ActualWidth;
            double num3 = Convert.ToDouble(this.MidGrid.ColumnDefinitions[1].Width.ToString());
            double num4 = Convert.ToDouble(this.MidGrid.ColumnDefinitions[2].Width.ToString());
            this.MidGrid.ColumnDefinitions[1].Width = new GridLength(715.0);
            double pixels = (((actualWidth - 715.0) - num4) - 30.0) / 2.0;
            pixels = (pixels > 0.0) ? pixels : 0.0;
            this.MidGrid.ColumnDefinitions[0].Width = new GridLength(pixels);
            this.MidGrid.ColumnDefinitions[3].Width = new GridLength(pixels);
        }

        private void cover_CloseStockChartCover(object sender, MouseEventArgs e)
        {
            this.LayoutRoot.Children.Remove(this.cover);
        }

        private void fullScreen_MouseEnter(object sender, MouseEventArgs e)
        {
        }

        private void fullScreen_MouseLeave(object sender, MouseEventArgs e)
        {
        }

        private void HiddenNewsArea()
        {
            this.right.RowDefinitions[2].Height = new GridLength(0.0);
            this.right.RowDefinitions[3].Height = new GridLength(0.0);
            this.NewsCanvas.Height = 0.0;
            this.newsInfoArea.Visibility = Visibility.Collapsed;
        }

        private void HiddenStockTopFix()
        {
            this.right.RowDefinitions[0].Height = new GridLength(0.0);
            this.right.RowDefinitions[1].Height = new GridLength(0.0);
            this.StockTopFiveCanvas.Height = 0.0;
            this.stockTopFiveChanges.Visibility = Visibility.Collapsed;
        }

        //[DebuggerNonUserCode]
        //public void InitializeComponent()
        //{
        //    if (!this._contentLoaded)
        //    {
        //        this._contentLoaded = true;
        //        Application.LoadComponent(this, new Uri("/SinaFinance;component/MainPage.xaml", UriKind.Relative));
        //        this.timeMouseEnter = (Storyboard) base.FindName("timeMouseEnter");
        //        this.timeMouseEnter_Copy1 = (Storyboard) base.FindName("timeMouseEnter_Copy1");
        //        this.KlineMouseEnter = (Storyboard) base.FindName("KlineMouseEnter");
        //        this.KlineMouseEnter_Copy1 = (Storyboard) base.FindName("KlineMouseEnter_Copy1");
        //        this.fullScreenMouseEnter = (Storyboard) base.FindName("fullScreenMouseEnter");
        //        this.fullScreenMouseEnter_Copy1 = (Storyboard) base.FindName("fullScreenMouseEnter_Copy1");
        //        this.start = (Storyboard) base.FindName("start");
        //        this.scrollViewer = (ScrollViewer) base.FindName("scrollViewer");
        //        this.LayoutRoot = (Grid) base.FindName("LayoutRoot");
        //        this.MidGrid = (Grid) base.FindName("MidGrid");
        //        this.right = (Grid) base.FindName("right");
        //        this.StockTopFiveCanvas = (Canvas) base.FindName("StockTopFiveCanvas");
        //        this.NewsCanvas = (Canvas) base.FindName("NewsCanvas");
        //        this.border = (Border) base.FindName("border");
        //        this.BasicInfoCanvas = (Canvas) base.FindName("BasicInfoCanvas");
        //        this.Timeborder = (Border) base.FindName("Timeborder");
        //        this.canvasT = (Canvas) base.FindName("canvasT");
        //        this.path = (Path) base.FindName("path");
        //        this.Kline = (Border) base.FindName("Kline");
        //        this.canvasK = (Canvas) base.FindName("canvasK");
        //        this.path1 = (Path) base.FindName("path1");
        //        this.fullScreen = (Border) base.FindName("fullScreen");
        //        this.canvasF = (Canvas) base.FindName("canvasF");
        //        this.btnFullScreemChart = (TextBlock) base.FindName("btnFullScreemChart");
        //        this.path2 = (Path) base.FindName("path2");
        //        this.border1 = (Border) base.FindName("border1");
        //        this.ChartCanvas = (Canvas) base.FindName("ChartCanvas");
        //        this.BottomGrid = (Grid) base.FindName("BottomGrid");
        //        this.top = (Grid) base.FindName("top");
        //        this.full = (Grid) base.FindName("full");
        //        this.topInfoCanvas = (Canvas) base.FindName("topInfoCanvas");
        //        this.popSearchArea = (Canvas) base.FindName("popSearchArea");
        //        this.SearchCanvas = (Canvas) base.FindName("SearchCanvas");
        //    }
        //}

        private void InitStock()
        {
            if (!Application.Current.IsRunningOutOfBrowser)
            {
                string cookie = CookieControl.GetCookie("cookie_history");
                List<string> list = null;
                if (!string.IsNullOrEmpty(cookie))
                {
                    list = cookie.Split(new char[] { '$' }).ToList<string>();
                    for (int i = list.Count - 1; i > -1; i--)
                    {
                        if (!list[i].Trim().Equals(string.Empty))
                        {
                            string[] strArray = list[i].Split(new char[] { '_' });
                            int length = strArray.Length;
                            if (length.Equals(3))
                            {
                                this.STOCKID = strArray[1];
                            }
                            break;
                        }
                    }
                }
            }
        }

        private void Kline_MouseEnter(object sender, MouseEventArgs e)
        {
        }

        private void Kline_MouseLeave(object sender, MouseEventArgs e)
        {
        }

        private void LayoutRoot_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.searchSgstHistory != null)
            {
                this.searchSgstHistory.OutsideListLoseFocus();
            }
        }

        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            this.path.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x40, 130, 0xff));
            this.path1.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x8d, 0x8d, 0x8d));
            this.path2.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x8d, 0x8d, 0x8d));
            this.tsvInfo = new TopStockView();
            this.tsvInfo.QueryMarketInfo += new TopStockView.EventHandler(this.tsvInfo_QueryMarketInfo);
            this.tsvInfo.GetBaseInfo("sh000001,sz399001");
            this.topInfoCanvas.Children.Add(this.tsvInfo);
            if (!Application.Current.IsRunningOutOfBrowser)
            {
                this.InitStock();
            }
            this.sbinfo = new StockBasicInfo();
            this.sbinfo.GetBaseInfo(this.STOCKID);
            this.BasicInfoCanvas.Children.Add(this.sbinfo);
            this.MainTargetID = this.STOCKID;
            this.slides = new Collection<UserControl>();
            this.kDayAxis = new KDayAxis();
            this.timeSharingAxis = new TimeSharingAxis();
            this.kDayAxis.StockNumber = this.STOCKID;
            this.timeSharingAxis.StockNumber = this.STOCKID;
            this.kDayAxis.Width = 700.0;
            this.timeSharingAxis.Width = 700.0;
            this.kDayAxis.Height = 400.0;
            this.timeSharingAxis.Height = 400.0;
            this.slides.Add(this.kDayAxis);
            this.slides.Add(this.timeSharingAxis);
            this.slideShow = new SlideShow();
            for (int i = this.slides.Count - 1; i >= 0; i--)
            {
                this.slideShow.Width = 700.0;
                this.slideShow.Slides.Add(this.slides[i]);
            }
            this.slideShow.CurrentSlide = 0;
            this.ChartCanvas.Children.Add(this.slideShow);
            this.timeSharingAxis.DoSearch += new System.EventHandler(this.timeSharingAxis_DoSearch);
            this.timeSharingAxis.DoQuery += new TimeSharingAxis.DoQueryEventHanlder(this.timeSharingAxis_DoQuery);
            this.timeSharingAxis.DoCompare += new TimeSharingAxis.CompareEventHanlder(this.timeSharingAxis_DoCompare);
            this.stockTopFiveChanges = new StockTopFiveChanges();
            this.stockTopFiveChanges.HorizontalAlignment = HorizontalAlignment.Left;
            this.stockTopFiveChanges.VerticalAlignment = VerticalAlignment.Top;
            this.stockTopFiveChanges.Width = this.StockTopFiveCanvas.Width;
            this.StockTopFiveCanvas.Children.Add(this.stockTopFiveChanges);
            this.stockTopFiveChanges.Margin = new Thickness(0.0, 10.0, 0.0, 0.0);
            this.newsInfoArea = new StockProfessionInformationArea();
            this.newsInfoArea.GenerateNewsInfo(this.STOCKID);
            this.NewsCanvas.Children.Add(this.newsInfoArea);
            this.cover.StockNumber = this.STOCKID;
            this.cover.SetValue(Canvas.ZIndexProperty, 200);
            this.cover.CloseStockChartCover += new StockChartCover.EventHandler(this.cover_CloseStockChartCover);
            this.searchSgstHistory = new SearchSuggestHistory();
            this.searchSgstHistory.PopUpSearchSymbol += new SearchSuggestHistory.PopUpSearchDelegate(this.searchSgstHistory_PopUpSearchSymbol);
            this.SearchCanvas.Children.Add(this.searchSgstHistory);
            if (this.MainTargetID.Equals("sh000001") || this.MainTargetID.Equals("sz399001"))
            {
                this.HiddenStockTopFix();
            }
            else
            {
                this.ShowStockTopFix();
            }
            this.isLoad = false;
        }

        private void scrollViewer_KeyDown(object sender, KeyEventArgs e)
        {
            if (this.slideShow != null)
            {
                this.slideShow.UserControl_KeyDown(sender, e);
                if (this.slideShow.CurrentPage.Equals(0))
                {
                    this.cover.Type = StockChartCover.StockChartTypeEnum.TimeSharing;
                    this.canvasK.Opacity = 0.5;
                    this.canvasF.Opacity = 0.5;
                    this.canvasT.Opacity = 1.0;
                }
                else
                {
                    this.cover.Type = StockChartCover.StockChartTypeEnum.KLine;
                    this.canvasK.Opacity = 1.0;
                    this.canvasF.Opacity = 0.5;
                    this.canvasT.Opacity = 0.5;
                }
            }
        }

        private void searchSgstHistory_PopUpSearchSymbol(string Symbol6, string Symbol8)
        {
            this.MainTargetID = Symbol8;
            this.sbinfo.GetBaseInfo(Symbol8);
            this.ChartCanvas.Children.Remove(this.slideShow);
            Collection<UserControl> collection = new Collection<UserControl>();
            this.kDayAxis = new KDayAxis();
            this.timeSharingAxis = new TimeSharingAxis();
            this.kDayAxis.StockNumber = Symbol8;
            this.timeSharingAxis.StockNumber = Symbol8;
            this.kDayAxis.Width = 700.0;
            this.timeSharingAxis.Width = 700.0;
            this.kDayAxis.Height = 400.0;
            this.timeSharingAxis.Height = 400.0;
            collection.Add(this.kDayAxis);
            collection.Add(this.timeSharingAxis);
            this.slideShow = new SlideShow();
            for (int i = collection.Count - 1; i >= 0; i--)
            {
                this.slideShow.Width = 700.0;
                this.slideShow.Slides.Add(collection[i]);
            }
            this.slideShow.CurrentSlide = 0;
            this.ChartCanvas.Children.Add(this.slideShow);
            this.newsInfoArea.GenerateNewsInfo(Symbol8);
            this.timeSharingAxis.DoSearch += new System.EventHandler(this.timeSharingAxis_DoSearch);
            this.timeSharingAxis.DoQuery += new TimeSharingAxis.DoQueryEventHanlder(this.timeSharingAxis_DoQuery);
            this.timeSharingAxis.DoCompare += new TimeSharingAxis.CompareEventHanlder(this.timeSharingAxis_DoCompare);
            if (this.MainTargetID.Equals("sh000001") || this.MainTargetID.Equals("sz399001"))
            {
                this.HiddenStockTopFix();
            }
            else
            {
                this.ShowStockTopFix();
            }
            this.path.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x40, 130, 0xff));
            this.path1.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x8d, 0x8d, 0x8d));
            this.path2.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x8d, 0x8d, 0x8d));
        }

        private void ShowNewsArea()
        {
            this.right.RowDefinitions[2].Height = new GridLength(31.0);
            this.right.RowDefinitions[3].Height = new GridLength(250.0);
            this.NewsCanvas.Height = 246.0;
            this.newsInfoArea.Visibility = Visibility.Visible;
        }

        private void ShowStockTopFix()
        {
            this.right.RowDefinitions[0].Height = new GridLength(31.0);
            this.right.RowDefinitions[1].Height = new GridLength(250.0);
            this.StockTopFiveCanvas.Height = 246.0;
            this.stockTopFiveChanges.Visibility = Visibility.Visible;
        }

        private void Timeborder_MouseEnter(object sender, MouseEventArgs e)
        {
        }

        private void Timeborder_MouseLeave(object sender, MouseEventArgs e)
        {
        }

        private void timeSharingAxis_DoCompare(object sender, RoutedEventArgs e)
        {
            CheckBox box = (CheckBox) sender;
            string str = box.Tag.ToString();
            if ((!str.Trim().Equals(string.Empty) && !str.IndexOf('^').Equals(-1)) && !this.MainTargetID.Equals(str.Split(new char[] { '^' })[1]))
            {
                this.ChartCanvas.Children.Remove(this.slideShow);
                Collection<UserControl> collection = new Collection<UserControl>();
                this.kDayAxis = new KDayAxis();
                this.timeSharingAxis = new TimeSharingAxis();
                this.kDayAxis.StockNumber = this.MainTargetID;
                this.timeSharingAxis.StockNumber = this.MainTargetID + "," + str.Split(new char[] { '^' })[1];
                this.kDayAxis.Width = 700.0;
                this.timeSharingAxis.Width = 700.0;
                this.kDayAxis.Height = 400.0;
                this.timeSharingAxis.Height = 400.0;
                collection.Add(this.kDayAxis);
                collection.Add(this.timeSharingAxis);
                this.slideShow = new SlideShow();
                for (int i = collection.Count - 1; i >= 0; i--)
                {
                    this.slideShow.Width = 700.0;
                    this.slideShow.Slides.Add(collection[i]);
                }
                this.slideShow.CurrentSlide = 0;
                this.ChartCanvas.Children.Add(this.slideShow);
                this.timeSharingAxis.DoCompare += new TimeSharingAxis.CompareEventHanlder(this.timeSharingAxis_DoCompare);
                this.timeSharingAxis.DoSearch += new System.EventHandler(this.timeSharingAxis_DoSearch);
                this.timeSharingAxis.DoQuery += new TimeSharingAxis.DoQueryEventHanlder(this.timeSharingAxis_DoQuery);
            }
        }

        private void timeSharingAxis_DoQuery(object sender, RoutedEventArgs e)
        {
            this.ChartCanvas.Children.Remove(this.slideShow);
            Collection<UserControl> collection = new Collection<UserControl>();
            this.kDayAxis = new KDayAxis();
            this.timeSharingAxis = new TimeSharingAxis();
            this.kDayAxis.StockNumber = this.MainTargetID;
            this.timeSharingAxis.StockNumber = this.MainTargetID;
            this.kDayAxis.Width = 700.0;
            this.timeSharingAxis.Width = 700.0;
            this.kDayAxis.Height = 400.0;
            this.timeSharingAxis.Height = 400.0;
            collection.Add(this.kDayAxis);
            collection.Add(this.timeSharingAxis);
            this.slideShow = new SlideShow();
            for (int i = collection.Count - 1; i >= 0; i--)
            {
                this.slideShow.Width = 700.0;
                this.slideShow.Slides.Add(collection[i]);
            }
            this.slideShow.CurrentSlide = 0;
            this.ChartCanvas.Children.Add(this.slideShow);
            this.timeSharingAxis.DoSearch += new System.EventHandler(this.timeSharingAxis_DoSearch);
            this.timeSharingAxis.DoQuery += new TimeSharingAxis.DoQueryEventHanlder(this.timeSharingAxis_DoQuery);
            this.timeSharingAxis.DoCompare += new TimeSharingAxis.CompareEventHanlder(this.timeSharingAxis_DoCompare);
        }

        private void timeSharingAxis_DoSearch(object sender, EventArgs e)
        {
            ComparationItem item = (ComparationItem) sender;
            string[] strArray = item.Tag.ToString().Split(new char[] { '^' });
            this.searchSgstHistory_PopUpSearchSymbol(strArray[0], strArray[1]);
            this.timeSharingAxis.DoSearch += new System.EventHandler(this.timeSharingAxis_DoSearch);
            this.timeSharingAxis.DoQuery += new TimeSharingAxis.DoQueryEventHanlder(this.timeSharingAxis_DoQuery);
            this.timeSharingAxis.DoCompare += new TimeSharingAxis.CompareEventHanlder(this.timeSharingAxis_DoCompare);
            if (!Application.Current.IsRunningOutOfBrowser)
            {
                CookieControl.AddItemtoHistoryView(strArray[0] + "_" + strArray[1] + "_" + strArray[2]);
            }
        }

        private void tsvInfo_QueryMarketInfo(object sender, MouseEventArgs e)
        {
            TextBlock block = (TextBlock) sender;
            this.MainTargetID = block.Tag.ToString();
            if (!Application.Current.IsRunningOutOfBrowser)
            {
                string str = string.Empty;
                if (this.MainTargetID == "sh000001")
                {
                    str = "上证指数";
                }
                else
                {
                    str = "深证成指";
                }
                CookieControl.AddItemtoHistoryView(this.MainTargetID.Substring(2, 6) + "_" + this.MainTargetID + "_" + str);
            }
            this.tsvInfo.GetBaseInfo("sh000001,sz399001");
            this.sbinfo.GetBaseInfo(this.MainTargetID);
            this.ChartCanvas.Children.Remove(this.slideShow);
            Collection<UserControl> collection = new Collection<UserControl>();
            this.kDayAxis = new KDayAxis();
            this.timeSharingAxis = new TimeSharingAxis();
            this.kDayAxis.StockNumber = this.MainTargetID;
            this.timeSharingAxis.StockNumber = this.MainTargetID;
            this.kDayAxis.Width = 700.0;
            this.timeSharingAxis.Width = 700.0;
            this.kDayAxis.Height = 400.0;
            this.timeSharingAxis.Height = 400.0;
            collection.Add(this.kDayAxis);
            collection.Add(this.timeSharingAxis);
            this.slideShow = new SlideShow();
            for (int i = collection.Count - 1; i >= 0; i--)
            {
                this.slideShow.Width = 700.0;
                this.slideShow.Slides.Add(collection[i]);
            }
            this.slideShow.CurrentSlide = 0;
            this.ChartCanvas.Children.Add(this.slideShow);
            this.newsInfoArea.GenerateNewsInfo(this.MainTargetID);
            this.timeSharingAxis.DoSearch += new System.EventHandler(this.timeSharingAxis_DoSearch);
            this.timeSharingAxis.DoQuery += new TimeSharingAxis.DoQueryEventHanlder(this.timeSharingAxis_DoQuery);
            this.timeSharingAxis.DoCompare += new TimeSharingAxis.CompareEventHanlder(this.timeSharingAxis_DoCompare);
            if (this.MainTargetID.Equals("sh000001") || this.MainTargetID.Equals("sz399001"))
            {
                this.HiddenStockTopFix();
            }
            else
            {
                this.ShowStockTopFix();
            }
            this.path.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x40, 130, 0xff));
            this.path1.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x8d, 0x8d, 0x8d));
            this.path2.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0x8d, 0x8d, 0x8d));
        }

        private void UserControl_KeyDown(object sender, KeyEventArgs e)
        {
            if (this.slideShow != null)
            {
                this.slideShow.UserControl_KeyDown(sender, e);
                if (this.slideShow.CurrentPage.Equals(0))
                {
                    this.cover.Type = StockChartCover.StockChartTypeEnum.TimeSharing;
                    this.canvasK.Opacity = 0.5;
                    this.canvasT.Opacity = 1.0;
                }
                else
                {
                    this.cover.Type = StockChartCover.StockChartTypeEnum.KLine;
                    this.canvasK.Opacity = 1.0;
                    this.canvasT.Opacity = 0.5;
                }
            }
        }

        public bool IsLoad
        {
            get
            {
                return this.isLoad;
            }
            set
            {
                this.isLoad = value;
            }
        }
    }
}
